package com.shuoyue.ycgk.ui.mine.info;


import com.google.gson.Gson;
import com.shuoyue.ycgk.base.BasePresenter;
import com.shuoyue.ycgk.base.BaseResult;
import com.shuoyue.ycgk.base.BaseView;
import com.shuoyue.ycgk.net.RetrofitClient;
import com.shuoyue.ycgk.net.base.ApiSubscriber;
import com.shuoyue.ycgk.net.base.ApiSubscriberNoView;
import com.shuoyue.ycgk.net.gsondefaultadapter.Optional;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import okhttp3.MediaType;
import okhttp3.RequestBody;

public interface UpdateNickContract {

    interface View extends BaseView {
        void sucess(String nickName, String head);
    }


    class Presenter extends BasePresenter<View> {
        Model model = new Model();

        public void updateUserInfo(String nick, String head) {
            apply(model.updateUserInfo(nick, head))
                    .subscribe(new ApiSubscriber<Optional<String>>(mView, this) {
                        @Override
                        public void onNext(Optional<String> stringOptional) {
                            super.onNext(stringOptional);
                            mView.sucess(nick, head);
                        }
                    });
        }
    }

    class Model {
        public Observable<BaseResult<String>> updateUserInfo(String nick, String head) {
            return RetrofitClient.getInstance().getApi().updateUserInfo(nick, head);
        }
    }
}
